import type { RepositoryVO, RepositoryForm, RepositoryQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
* 查询知识库列表
* @param params
* @returns 知识库列表
*/
export function repositoryList(params?: RepositoryQuery) {
  return requestClient.get<PageResult<RepositoryVO>>('/business/knowledge/list', { params });
}

/**
 * 导出知识库列表
 * @param params
 * @returns 知识库列表
 */
export function repositoryExport(params?: RepositoryQuery) {
  return commonExport('/business/knowledge/export', params ?? {});
}

/**
 * 查询知识库详情
 * @param id id
 * @returns 知识库详情
 */
export function repositoryInfo(id: ID) {
  return requestClient.get<RepositoryVO>(`/business/knowledge/${id}`);
}

/**
 * 新增知识库
 * @param data
 * @returns void
 */
export function repositoryAdd(data: RepositoryForm) {
  return requestClient.postWithMsg<void>('/business/knowledge', data);
}

/**
 * 更新知识库
 * @param data
 * @returns void
 */
export function repositoryUpdate(data: RepositoryForm) {
  return requestClient.putWithMsg<void>('/business/knowledge', data);
}

/**
 * 删除知识库
 * @param id id
 * @returns void
 */
export function repositoryRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/business/knowledge/${id}`);
}
